package sort

import "fmt"

func quickSort(data []int, low, high int) {
	if high <= low {
		return
	}
	mid := partition(data, low, high)
	quickSort(data, low, mid-1)
	quickSort(data, mid+1, high)
}
func partition(data []int, low, high int) int {
	i := low + 1
	j := high
	for true {
		for ; i < high+1; i++ {
			if data[i] > data[low] {
				break
			}
		}
		for ; j > low; j-- {
			if data[j] <= data[low] {
				break
			}
		}
		if i >= j {
			break
		}
		data[i], data[j] = data[j], data[i]
	}
	data[low], data[j] = data[j], data[low]
	fmt.Println(j, data)
	return j
}
